#include <bits/stdc++.h>
using namespace std;
int n, m, L, V;
struct node
{
    int d, v, a;
} e[100005];
int p[100005];
pair<int, int> q[100005];
int pos;
int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int T;
    scanf("%d", &T);
    while (T--)
    {
        scanf("%d%d%d%d", &n, &m, &L, &V);
        pos = 0;
        for (int i = 1; i <= n; i++)
            scanf("%d%d%d", &e[i].d, &e[i].v, &e[i].a);
        for (int i = 1; i <= m; i++)
            scanf("%d", p + i);
        for (int i = 1; i <= n; i++)
        {
            int st = 1e9, ed = -1;
            for (int j = 1; j <= m; j++)
            {
                if (p[j] >= e[i].d)
                {
                    if (e[i].v * e[i].v + 2 * e[i].a * (p[j] - e[i].d) > V * V)
                        st = min(st, j), ed = max(ed, j);
                        else if (e[i].a == 0)
                            break;
                }
            }
            if (st != 1e9)
                q[++pos] = {st, ed};
        }
        printf("%d ", pos);
        sort(q + 1, q + 1 + pos);
        int ans = m;
        if (pos != 0)
                ans--;
        for (int i = 2; i <= pos; i++)
        {
            if (q[i].first > q[i - 1].second)
            {
                ans--;
                continue;
            }
            q[i] = {q[i].first,min(q[i-1].second,q[i].second)};
        }
        printf("%d\n",ans);
    }
    return 0;
}
